package com.example.mobile2021606140lhq0405;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity01 extends AppCompatActivity {

    private TextView tvMainTitle;
    private EditText edtTxtMain01;
    private EditText edtTxtMain02;
    private EditText edtTxtMain03;
    private EditText edtTxtMain04;
    private Button btnMain01;
    private EditText edtTxtMain000;
    private int a, b;
    String c;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main01);
        initView();

        btnMain01.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                a = Integer.valueOf(edtTxtMain03.getText().toString()).intValue();
                b = Integer.parseInt(edtTxtMain04.getText().toString());
                c = String.valueOf(a + b);
                edtTxtMain000.setText(c);
            }
        });
    }

    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        edtTxtMain01 = (EditText) findViewById(R.id.edtTxt_main_01);
        edtTxtMain02 = (EditText) findViewById(R.id.edtTxt_main_02);
        edtTxtMain03 = (EditText) findViewById(R.id.edtTxt_main_03);
        edtTxtMain04 = (EditText) findViewById(R.id.edtTxt_main_04);
        btnMain01 = (Button) findViewById(R.id.btn_main_01);
        edtTxtMain000 = findViewById(R.id.edtTxt_main_000);
    }
}